package com.djp.smartapp.dialog;

import android.view.View;

import com.djp.smartapp.MainActivity;
import com.lenovo.manufacture.R;

public class OnClickManager {
    //单例模式
    private static OnClickManager onClickManager;
    private OnClickManager() {
    }
    public static OnClickManager getOnClickManager(){
        if (onClickManager ==null) onClickManager = new OnClickManager();
        return onClickManager;
    }

    /**
     * 通过判断用户点击的button显示相应的dialog
     * @param view view
     * @param activity activity本身
     * @return 返回自定义的dialog
     */
    public MyDialog getMyDialog(View view, MainActivity activity) {
        switch (view.getId()) {
            case R.id.btn_create_line:
                return new CreateLineDialog(activity);
            case R.id.btn_get_people:
                return new GetPeopleDialog(activity);
            default:
                UniversalDialog universalDialog = new UniversalDialog(activity);
                universalDialog.setText("提示","模式选择错误或这个模式还没有准备好。");
                return universalDialog;
        }
    }
}
